home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / kiss-0.11 / kiss-0 / kiss / src / domore.c < prev    next >
C/C++ Source or Header  |  1995-03-23  |  864b  |  54 lines

  1. #include "kiss.h"
  2.  
  3. int domore (Stringstack s)
  4. {
  5.     register int
  6.     opt,
  7.     ret = 0,
  8.     morefiles,
  9.     i;
  10.     FILE
  11.     *altstdin,
  12.     *f;
  13.  
  14.     while ( (opt = getopt (s.nstr, s.str, "h")) != -1 )
  15.     switch (opt)
  16.     {
  17.         case 'h':
  18.         default:
  19.         error ("Bad commandline.\n"
  20.                "Usage: %s file(s)\n",
  21.                progname);
  22.     }
  23.     
  24.     if (! isatty (fileno (stdout)))
  25.     return (docat (s));
  26.  
  27.     if (s.nstr == 1)
  28.     {
  29.     if (! (altstdin = fopen (DEVTTY, "r")) )
  30.         error ("cannot open \"%s\" as alternate stdin", DEVTTY);
  31.     morefile (stdin, "stdin", 0, altstdin);
  32.     }
  33.     else
  34.     {
  35.     for (i = 1; i < s.nstr; i++)
  36.     {
  37.         if (! (f = fopen (s.str [i], "r")) )
  38.         ret += warning ("cannot open \"%s\"", s.str [i]);
  39.         else
  40.         {
  41.         morefiles = morefile (f, s.str [i], s.nstr > 2, stdin);
  42.         fclose (f);
  43.         if (! morefiles)
  44.             break;
  45.         }
  46.     }
  47.     }
  48.     
  49.     return (ret);
  50. }
  51.     
  52.  
  53.     
  54.